import cgi
from google.appengine.api import users
import webapp2

MAIN_PAGE_HTML = """\
<html>
  <body>
    <h1>Welcome to Connexus!</h1>
    <h3>Share the world!</h3>
    <form action="/sign" method="post">
      <div><input type="text" name="userID" value="Gmail UserID"></div>
      <div><input type="text" name="userPWD" value="Gmail Password"></div>
    </form>
    <p>
    <a href="/manage">manage</a> to the manage page.
    </p>
  </body>
</html>
"""

MANAGE_PAGE_HTML = """\
<html>
  <body>
    <h1>Connex.us</h1>
    <p>
    <a href="/manage" target="/manage">Manage</a> |
    <a href="/create" target="/create">Create</a> |
    <a href="/viewSingle" target="/viewSingle">View</a> |
    <a href="/search" target="/search">Search</a> |
    <a href="/trending" target="/trending">Trending</a> |
    <a href="/social" target="/social">Social</a> |
    </p>
    <p>
    Streams I own
    </p>
    <p>
    Streams I subscibe to
    </p>
  </body>
</html>
"""

CREATE_PAGE_HTML = """\
<html>
  <body>
    <h1>Connex.us</h1>
    <p>
    <a href="/manage" target="/manage">Manage</a> |
    <a href="/create" target="/create">Create</a> |
    <a href="/viewSingle" target="/viewSingle">View</a> |
    <a href="/search" target="/search">Search</a> |
    <a href="/trending" target="/trending">Trending</a> |
    <a href="/social" target="/social">Social</a> |
    </p>
  </body>
</html>
"""

VIEWSINGLE_PAGE_HTML = """\
<html>
  <body>
    <h1>Connex.us</h1>
    <p>
    <a href="/manage" target="/manage">Manage</a> |
    <a href="/create" target="/create">Create</a> |
    <a href="/viewSingle" target="/viewSingle">View</a> |
    <a href="/search" target="/search">Search</a> |
    <a href="/trending" target="/trending">Trending</a> |
    <a href="/social" target="/social">Social</a> |
    </p>
    <p>
    <img src="Koala.jpg" alt=""> <a href="/viewAll" target="/viewAll">More Pictures</a>
    </p>
    <input type="text" name="FileName" value="File Name"><input type="text" name="comments" value="Comments">
  </body>
</html>
"""

VIEWALL_PAGE_HTML = """\
<html>
  <body>
    <h1>Connex.us</h1>
    <p>
    <a href="/manage" target="/manage">Manage</a> |
    <a href="/create" target="/create">Create</a> |
    <a href="/viewSingle" target="/viewSingle">View</a> |
    <a href="/search" target="/search">Search</a> |
    <a href="/trending" target="/trending">Trending</a> |
    <a href="/social" target="/social">Social</a> |
    </p>
    <h2>View All Streams</h2>
  </body>
</html>
"""

ERROR_PAGE_HTML = """\
<html>
  <body>
    <h1>Connex.us</h1>
    <p>
    <a href="/manage" target="/manage">Manage</a> |
    <a href="/create" target="/create">Create</a> |
    <a href="/viewSingle" target="/viewSingle">View</a> |
    <a href="/search" target="/search">Search</a> |
    <a href="/trending" target="/trending">Trending</a> |
    <a href="/social" target="/social">Social</a> |
    </p>
    <p>
    Error: you tried to create a new stream <br>
    whose name is the same as an <br>
    existing stream; operation did not complete.
    </p>
  </body>
</html>
"""

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.write(MAIN_PAGE_HTML)

class managePG(webapp2.RequestHandler):
    def get(self):
        self.response.write(MANAGE_PAGE_HTML)

class createPG(webapp2.RequestHandler):
    def get(self):
        self.response.write(CREATE_PAGE_HTML)

class viewSinglePG(webapp2.RequestHandler):
    def get(self):
        self.response.write(VIEWSINGLE_PAGE_HTML)

class viewAllPG(webapp2.RequestHandler):
    def get(self):
        self.response.write(VIEWALL_PAGE_HTML)

class errorPG(webapp2.RequestHandler):
    def get(self):
        self.response.write(ERROR_PAGE_HTML)

application = webapp2.WSGIApplication([
    ('/', MainPage),
    ('/manage', managePG),
    ('/create', createPG),
    ('/viewSingle', viewSinglePG),
    ('/viewAll', viewAllPG),
    #('/search', searchPG),
    #('/trending', trendPG),
    ('/error', errorPG),
], debug=True)
